package com.mtcarpenter.common;

import java.util.Objects;

/**
 * @Author: mtcarpenter
 * @describe
 * @Date: 2019/10/6
 * @Version 1.0
 */
public class Fruit {
    /** id */
    private int id;
    /** 水果名 */
    private String name;
    /** 数量 */
    private int num;
    /** 价格 */
    private double price;

    /** 类型*/
    private int type;



    public Fruit() {
    }

    public Fruit(String name) {
        this.name = name;
    }

    public Fruit(int id, String name, int num, double price, int type) {
        this.id = id;
        this.name = name;
        this.num = num;
        this.price = price;
        this.type = type;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "Fruit{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", num=" + num +
                ", price=" + price +
                ", type=" + type +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Fruit fruit = (Fruit) o;
        if (id != fruit.id) {
            return false;
        }
        if (num != fruit.num) {
            return false;
        }
        if (Double.compare(fruit.price, price) != 0) {
            return false;
        }
        return Objects.equals(name, fruit.name);
    }
    @Override
    public int hashCode() {
        int result;
        result = id;
        result = 31 * result + name.hashCode();
        result = 31 * result + num;
        long temp = Double.doubleToLongBits(price);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        return result;
    }

}
